/*
 * @version: vue3
 * @Author: lxs
 * @Date: 2022-04-27 15:45:41
 * @LastEditors: sueRimn
 * @LastEditTime: 2022-05-01 12:17:43
 */
import { InjectionKey } from "vue";
import { createStore, useStore as baseUseStore, Store } from "vuex";
import tabs, { TabsState } from "../store/modules/tabs";
import menu, { MenuState } from "../store/modules/menu";
import user, { UserState } from "../store/modules/user";
// 类型
export type RootState = {
  tabs: TabsState;
  menu: MenuState;
  user: UserState;
};
// 导入所有的模块
const modules = {
  tabs: tabs,
  menu: menu,
  user: user,
};
export const key: InjectionKey<Store<RootState>> = Symbol();

export const store = createStore<RootState>({
  modules,
});
export function useStore() {
  return baseUseStore(key);
}
